import request from '@/utils/request'
import store from '@/store'
export function fetchList(query) {
  const user_id = store.getters.user_id;
  return request({
    url: `/api/${user_id}/articles`,
    method: 'get',
    params: query
  })
}

export function fetchArticle(id) {
  const user_id = store.getters.user_id;
  return request({
    url: `/api/${user_id}/articles/${id}`,
    method: 'get',
    params: { }
  })
}

export function createArticle(data) {
  const user_id = store.getters.user_id;
  return request({
    url: `/api/${user_id}/articles`,
    method: 'post',
    data
  })
}

export function updateArticle(data) {
  const user_id = store.getters.user_id;
  return request({
    url: `/api/${user_id}/articles/${data.article_id}`,
    method: 'put',
    data
  })
}

export function deleteArticle(data) {
  const user_id = store.getters.user_id;
  return request({
    url: `/api/${user_id}/articles/${data.article_id}`,
    method: 'delete'
  })
}
